home *** CD-ROM | disk | FTP | other *** search
/ Champak 123 / (Vol 123) Jan 13 2011.iso / Games / island_fishing.swf / scripts / DefineSprite_221 / frame_1 / DoAction.as
Text File  |  2011-01-13  |  1KB  |  53 lines

  1. stop();
  2. flashing = 0;
  3. acceleration = 50;
  4. newpos = function()
  5. {
  6.    ranx = Math.round(Math.random() * 550);
  7.    rany = Math.round(Math.random() * 400);
  8. };
  9. newpos();
  10. this.onEnterFrame = function()
  11. {
  12.    if(hooked <= 0)
  13.    {
  14.       if(ranx > this._x)
  15.       {
  16.          this._xscale = 100;
  17.       }
  18.       if(ranx < this._x)
  19.       {
  20.          this._xscale = -100;
  21.       }
  22.       this._x += (ranx - this._x) / acceleration;
  23.       if(this._y > 213)
  24.       {
  25.          if(right >= 1)
  26.          {
  27.             myRadians = Math.atan2(rany - this._y,ranx - this._x);
  28.             myDegrees = Math.round(myRadians * 180 / 3.141592653589793);
  29.             this._rotation = myDegrees;
  30.          }
  31.          if(left >= 1)
  32.          {
  33.             myRadians = Math.atan2(rany - this._y,ranx + this._x);
  34.             myDegrees = Math.round(myRadians * 180 / 3.141592653589793);
  35.             this._rotation = myDegrees;
  36.          }
  37.          this._y += (rany - this._y) / acceleration;
  38.          if(rany <= 175)
  39.          {
  40.             newpos();
  41.          }
  42.       }
  43.       else
  44.       {
  45.          this._y += 1;
  46.       }
  47.       if(_root.smove >= 1)
  48.       {
  49.          newpos();
  50.       }
  51.    }
  52. };
  53.